CREATE TABLE `SRTrade`.`MsgSRPairLeggerLegState` (
`orderNumber` BIGINT NOT NULL DEFAULT 0 COMMENT 'PairLegger order number',
`side` ENUM('None','Buy','Sell') NOT NULL DEFAULT 'None',
`spdrSource` ENUM('None','SpdrTicket','SpdrSingle','SRSE','FIX','HedgeTool','TradeHedge','OpenHedge','AutoHedge','Orphan','RiskManager','OrderManager','ManagedOrder','RFQRespSrvr','Legger','SRSEDrop','FixDrop','TicketDrop','SysTest','RFRResponse','AllocOmni','AllocClient','CertGateway','MLegResponse','LeggerX','DropManager','AutoHedgeSrvr','AuctionStrategySrvr','AllocBlockFace','AllocBlockCust','IceChatGateway','EXS2SRC','MLinkResponse','AutoResponderVD','AutoResponderRC','AutoResponderSN','AutoResponderBX','MLink','SymChatGateway') NOT NULL DEFAULT 'None',
`accnt` VARCHAR(16) NOT NULL DEFAULT '' COMMENT 'SR trading account',
`clientFirm` VARCHAR(16) NOT NULL DEFAULT '' COMMENT 'SR client firm',
`secKey_at` ENUM('None','EQT','IDX','BND','CUR','COM','FUT','SYN','WAR','FLX','MUT','SPD','MM','MF','COIN','TOKEN','ANY') NOT NULL DEFAULT 'None' COMMENT 'leg Security (can be a stock, future, optExpiry, or option) [must be the same for all legs] [cp can be call, put, or both if secType = optExpiry]',
`secKey_ts` ENUM('None','SR','NMS','CME','ICE','CFE','CBOT','NYMEX','COMEX','RUT','CIDX','ARCA','NYSE','OTC','NSDQ','MFQS','MIAX','DJI','CUSIP','ISIN','BXE','EUX','ANY','CXE','DXE','NXAM','NXBR','NXLS','NXML','NXOS','NXP','EUREX','CEDX','ICEFE') NOT NULL DEFAULT 'None' COMMENT 'leg Security (can be a stock, future, optExpiry, or option) [must be the same for all legs] [cp can be call, put, or both if secType = optExpiry]',
`secKey_tk` VARCHAR(12) NOT NULL DEFAULT '' COMMENT 'leg Security (can be a stock, future, optExpiry, or option) [must be the same for all legs] [cp can be call, put, or both if secType = optExpiry]',
`secKey_yr` SMALLINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'leg Security (can be a stock, future, optExpiry, or option) [must be the same for all legs] [cp can be call, put, or both if secType = optExpiry]',
`secKey_mn` TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'leg Security (can be a stock, future, optExpiry, or option) [must be the same for all legs] [cp can be call, put, or both if secType = optExpiry]',
`secKey_dy` TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'leg Security (can be a stock, future, optExpiry, or option) [must be the same for all legs] [cp can be call, put, or both if secType = optExpiry]',
`secKey_xx` DOUBLE NOT NULL DEFAULT 0 COMMENT 'leg Security (can be a stock, future, optExpiry, or option) [must be the same for all legs] [cp can be call, put, or both if secType = optExpiry]',
`secKey_cp` ENUM('Call','Put','Pair') NOT NULL DEFAULT 'Call' COMMENT 'leg Security (can be a stock, future, optExpiry, or option) [must be the same for all legs] [cp can be call, put, or both if secType = optExpiry]',
`secType` ENUM('None','Stock','Future','OptExpiry','Option') NOT NULL DEFAULT 'None' COMMENT 'note: stock/stock, stock/future, future/future, optExpiry/optExpiry or option/option are allowed',
`ratio` SMALLINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'leg ratio (note: can be in shares, contracts, vega, wvega, tvega, or wtvega terms) (optExpiry must be in one of the xVega choices)',
`ratioType` ENUM('None','Qty','Vega','WVega','TVega','WtVega') NOT NULL DEFAULT 'None',
`legPriority` ENUM('None','Lead') NOT NULL DEFAULT 'None' COMMENT 'Lead leg(s) fill first (note: if there are no lead legs the first leg in the list will be treated as the lead leg)',
`legLimitType` ENUM('None','Prc','StrikeVol','AtmVol') NOT NULL DEFAULT 'None' COMMENT 'leg limit type (stock: Price, future: Price, optExpiry: AtmVol only, option: Price or StrikeVol)',
`posType` ENUM('None','Opening','Closing','Auto') NOT NULL DEFAULT 'None' COMMENT 'note: must be Auto for optExpiry (not required for stock)',
`ssaleFlag` ENUM('None','Long','Short','Exempt','Auto','Open','Close','Cover','NA') NOT NULL DEFAULT 'None' COMMENT 'only for stock legs (and autohedging)',
`hedgeInstrument` ENUM('None','Default','FrontMonth','Stock','Future') NOT NULL DEFAULT 'None',
`hedgeSecKey_at` ENUM('None','EQT','IDX','BND','CUR','COM','FUT','SYN','WAR','FLX','MUT','SPD','MM','MF','COIN','TOKEN','ANY') NOT NULL DEFAULT 'None' COMMENT 'autohedge instrument (can be a TickerKey (stock) or ExpiryKey (future)) [required for Stock and Future]',
`hedgeSecKey_ts` ENUM('None','SR','NMS','CME','ICE','CFE','CBOT','NYMEX','COMEX','RUT','CIDX','ARCA','NYSE','OTC','NSDQ','MFQS','MIAX','DJI','CUSIP','ISIN','BXE','EUX','ANY','CXE','DXE','NXAM','NXBR','NXLS','NXML','NXOS','NXP','EUREX','CEDX','ICEFE') NOT NULL DEFAULT 'None' COMMENT 'autohedge instrument (can be a TickerKey (stock) or ExpiryKey (future)) [required for Stock and Future]',
`hedgeSecKey_tk` VARCHAR(12) NOT NULL DEFAULT '' COMMENT 'autohedge instrument (can be a TickerKey (stock) or ExpiryKey (future)) [required for Stock and Future]',
`hedgeSecKey_yr` SMALLINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'autohedge instrument (can be a TickerKey (stock) or ExpiryKey (future)) [required for Stock and Future]',
`hedgeSecKey_mn` TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'autohedge instrument (can be a TickerKey (stock) or ExpiryKey (future)) [required for Stock and Future]',
`hedgeSecKey_dy` TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'autohedge instrument (can be a TickerKey (stock) or ExpiryKey (future)) [required for Stock and Future]',
`orderSize` INT NOT NULL DEFAULT 0 COMMENT 'working size (from parentBrkrState.orderSize) (sum of all individual orders; in cn/share terms)',
`orderActiveSize` INT NOT NULL DEFAULT 0 COMMENT 'order active size (from parentBrkrState.orderActiveSize) (sum of all individual orders; in cn/share terms)',
`numActiveBrkrs` SMALLINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'number of parent order legs with leg.activeSize > leg.cumFillQty',
`numAvailLegBrkrs` SMALLINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'number of parent order legs created',
`cumFillQty` DOUBLE NOT NULL DEFAULT 0 COMMENT 'in LeggerLimitType terms',
`avgFillPrc` DOUBLE NOT NULL DEFAULT 0,
`activeSprdSize` DOUBLE NOT NULL DEFAULT 0 COMMENT 'active size (sum of all individual orders; in ratio type terms)',
`legStatus` TINYTEXT NOT NULL DEFAULT '',
`targetState` ENUM('None','Take','Post') NOT NULL DEFAULT 'None',
`targetSprdSize` FLOAT NOT NULL DEFAULT 0,
`targetLimitPrice` FLOAT NOT NULL DEFAULT 0,
`bestBidPrc` FLOAT NOT NULL DEFAULT 0 COMMENT 'leg best bid price (in terms of limit type)',
`bestAskPrc` FLOAT NOT NULL DEFAULT 0 COMMENT 'leg best ask price',
`bestBidSize` FLOAT NOT NULL DEFAULT 0 COMMENT 'leg best bid size (in terms of ratio type)',
`bestAskSize` FLOAT NOT NULL DEFAULT 0 COMMENT 'leg best ask size',
`numNewOrders` INT NOT NULL DEFAULT 0 COMMENT 'number of parent orders published',
`numLimitUpdates` INT NOT NULL DEFAULT 0 COMMENT 'number of parent limit messages published',
`timestamp` DATETIME(6) NOT NULL DEFAULT '1900-01-01 00:00:00.000000',
PRIMARY KEY USING HASH (`orderNumber`,`side`)
) ENGINE=SRSE DEFAULT CHARSET=LATIN1 COMMENT='';